@using OrchardCore.DisplayManagement.Views
@using OrchardCore.ContentTypes.Deployment
@model ShapeViewModel<ContentDefinitionDeploymentStep>
@inject OrchardCore.ContentManagement.Metadata.IContentDefinitionManager ContentDefinitionManager

<h5>@T["Content Definitions"]</h5>

@if (Model.Value.IncludeAll)
{
    <span class="badge badge-success">All</span>
}
else
{
    var contentTypes = Model.Value.ContentTypes;
    var contentParts = Model.Value.ContentParts;

    var allTypes = ContentDefinitionManager.ListTypeDefinitions();
    var allParts = ContentDefinitionManager.ListPartDefinitions();

    var avaParts = allParts.Where(x => !allTypes.Any(y => y.Name == x.Name));

    if (contentTypes?.Length > 0)
    {
        foreach (var def in ContentDefinitionManager.ListTypeDefinitions())
        {
            if (contentTypes.Contains(def.Name))
            {
                <span class="badge badge-info">@def.DisplayName</span>
            }
        }
    }

    if (contentParts?.Length > 0)
    {
        foreach (var part in avaParts)
        {
            if (contentParts.Contains(part.Name))
            {
                <span class="badge badge-dark">@part.Name</span>
            }
        }
    }
}
